//
//  DSXButton.m
//  XiangBaLao
//
//  Created by Apple on 15/12/23.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "DSXButton.h"

@implementation DSXButton
@synthesize style = _style;

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        self.layer.cornerRadius = 5.0;
        self.layer.masksToBounds = YES;
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor colorWithRed:0.81 green:0.80 blue:0.81 alpha:1.00].CGColor;
        self.style = DSXButtonStyleDefault;
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame style:(DSXButtonStyle)style{
    if (self = [self initWithFrame:frame]) {
        self.style = style;
    }
    return self;
}

- (void)setStyle:(DSXButtonStyle)style{
    _style = style;
    switch (style) {
        case DSXButtonStyleDefault:
            [self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"orange.png"]]];
            [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [self setBackgroundImage:[UIImage imageNamed:@"B73D08.png"] forState:UIControlStateHighlighted];
            [self.layer setBorderColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"orange.png"]].CGColor];
            break;
        case DSXButtonStyleWhite:
            [self setBackgroundColor:[UIColor whiteColor]];
            [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [self setBackgroundImage:[UIImage imageNamed:@"E0.png"] forState:UIControlStateHighlighted];
            [self.layer setBorderColor:[UIColor colorWithRed:0.81 green:0.80 blue:0.81 alpha:1.00].CGColor];
            break;
        default:
            break;
    }
}

@end
